//
//  JGMyBadOrderController.m
//  JGRider
//
//  Created by 单启志 on 2018/1/26.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGMyBadOrderController.h"
#import "JGMyBadOrderCell.h"
#import "JGOrderModel.h"
@interface JGMyBadOrderController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *datas;
@end

@implementation JGMyBadOrderController
static NSString *cellId=@"myBadOrderCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configSubviews];
}

-(void)configSubviews{
    self.title=@"我的差评";
    self.datas=[JGOrderModel models];
    [self.view addSubview:self.tableView];
    
}

#pragma mark - tableview delegate

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
   UIView *headView=[[[NSBundle mainBundle]loadNibNamed:@"JGMybadOrderHeadView" owner:nil options:nil]lastObject];
    return headView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return AdaptedHeight(130);//147;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [[UIView alloc]init];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.datas.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
   return [tableView fd_heightForCellWithIdentifier:cellId configuration:^(JGMyBadOrderCell *cell) {
       cell.model=self.datas[indexPath.row];
    }];
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    JGMyBadOrderCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
    cell.model=self.datas[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
}

#pragma mark - override

-(UIColor *)lmjNavigationBackgroundColor:(LMJNavigationBar *)navigationBar{

    return HEXCOLOR(0x343434);
}

#pragma mark - getter setter
-(UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView =[[UITableView alloc]initWithFrame:CGRectMake(0,self.lmj_navgationBar.height, JGScreenW, JGScreenH-self.lmj_navgationBar.height) style:UITableViewStyleGrouped];
        
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([JGMyBadOrderCell class]) bundle:nil] forCellReuseIdentifier:cellId];
        //[_tableView setBackgroundColor:[UIColor redColor]];
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        _tableView.delegate=self;
        _tableView.dataSource=self;
    }
    
    return _tableView;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
